#   库的引用
import os.path

import PyQt6.QtWidgets as QtWidgets
import PyQt6.QtGui as QtGui

#   今日事件
class Today(QtWidgets.QFrame):
    def __init__(self):
        super().__init__()
        self.basePath = os.path.dirname(os.path.abspath(__file__))
        self.initUI()

    def initUI(self):
        #   设置主题
        self.stylePath = os.path.join(self.basePath, "Qss/today.qss")
        self.qssFile = open(self.stylePath, 'r')
        self.qssStyle = self.qssFile.read()
        self.setStyleSheet(self.qssStyle)

        #   主Layout
        self.vbox = QtWidgets.QVBoxLayout()
        self.vbox.setContentsMargins(0, 0, 0, 0)
        self.vbox.setSpacing(6)
        self.setLayout(self.vbox)

        #   事件列表
        self.todoList = QtWidgets.QListWidget()
        self.vbox.addWidget(self.todoList)

        #   操作与信息栏
        self.ctrlWidget = QtWidgets.QWidget()
        self.vbox.addWidget(self.ctrlWidget)
        self.ctrlLayout = QtWidgets.QHBoxLayout()
        self.ctrlLayout.setContentsMargins(0, 0, 0, 0)
        self.ctrlLayout.setSpacing(6)
        self.ctrlWidget.setLayout(self.ctrlLayout)

        self.labInfo = QtWidgets.QLabel("今日共0项事件，已完成0项，进度100%")
        self.ctrlLayout.addWidget(self.labInfo)
        self.ctrlLayout.addStretch(1)

        self.btnOK = QtWidgets.QPushButton("完成")
        self.iconPath = os.path.join(self.basePath, "Icon/ok.png")
        self.btnOK.setIcon(QtGui.QIcon(self.iconPath))
        self.ctrlLayout.addWidget(self.btnOK)

        self.btnNO = QtWidgets.QPushButton("放弃")
        self.iconPath = os.path.join(self.basePath, "Icon/no.png")
        self.btnNO.setIcon(QtGui.QIcon(self.iconPath))
        self.ctrlLayout.addWidget(self.btnNO)

        self.btnIgnore = QtWidgets.QPushButton("忽略")
        self.iconPath = os.path.join(self.basePath, "Icon/ignore.png")
        self.btnIgnore.setIcon(QtGui.QIcon(self.iconPath))
        self.ctrlLayout.addWidget(self.btnIgnore)

    def kickItem(self):
        self.todoList.setStyleSheet("QListView::item:selected{background: #cce4f7}")
        selectedRow = self.todoList.currentRow()
        item = self.todoList.takeItem(selectedRow)
        del item